package com.ifly.task.enums;

/**
 * @program: mypro
 * @description: todo 勇士、武士、将军、文士、辩士、谋士、军师、国士、烈士、男士、女士
 * @author: xuYao2
 * @create: 2022-07-22 14:07
 **/
public enum TypeEnum {
    EMPEROR(1, "君王"),
    BRAVE_MAN(2, "勇士"),
    SAMURAI(3, "武士"),
    GENERAL(4, "将军"),
    LITERATI(5, "文士"),
    TRAIN_SERVICE(6, "辩士"),
    SOPHIST(7, "谋士"),
    MILITARY_ADVISER(8, "军师"),
    UNIQUE(9, "国士"),
    MARTYR(10, "烈士"),
    MALE(11, "男士"),
    FEMALE(12, "女士");

    private final Integer value;
    private final String describe;

    TypeEnum(Integer value, String detail){
        this.value = value;
        this.describe = detail;
    }

    public Integer getValue(){
        return value;
    }

    public String getDescribe(){
        return describe;
    }

    /**
     * 根据value获取describe
     * @param value
     * @return
     */
    public static String getDescribe(Integer value) {
        for (TypeEnum en : TypeEnum.values()) {
            if (en.getValue().equals(value)) {
                return en.getDescribe();
            }
        }
        return "error";
    }

    /**
     * 根据describe获取value
     * @param describe
     * @return
     */
    public static Integer getValue(String describe){
        for (TypeEnum en : TypeEnum.values()) {
            if (en.getDescribe().equals(describe)) {
                return en.getValue();
            }
        }
        return -1;
    }

}
